package com.atguigu.config;

import com.atguigu.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * 配置类就是以前的配置文件
 */
@Configuration //告诉spring这是一个配置类
@ComponentScan(basePackages = "com.atguigu", excludeFilters = {
        //排除Controller和Service
        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})
}) //替换xml中<context:component-scan
public class MainConfig {
    /**
     * 返回的bean 中id默认就是方法名,默认是name标记为主
     * @return
     */
    @Bean(name = "person01")
    public Person person02() {
        return new Person("steven1", 20);
    }
}
